package com.runmyai.aitools.controller;

import com.runmyai.aitools.model.AiResponse;
import com.runmyai.aitools.model.ContentInfo;
import com.runmyai.aitools.service.AiService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 林瑶
 * @Description TODO
 * @Date 2024/2/3 20:53
 */
@Controller
public class AiController {
    @Resource
    private AiService aiService;

    @PostMapping(value = "/api/aichat/{content}")
    public List<String> aiChat(@PathVariable String content){
        ContentInfo contentInfo = new ContentInfo(content);
        AiResponse aiResponse = aiService.startAigc("{{content}}，请根据上述描写，生成 {{num}}条回答", contentInfo, 1);
        List<String> data = aiResponse.getData();
        data.forEach(item -> System.out.println(item));
        return data;
    }
}
